<?php
class Model_comment extends CI_Model{
    function insertComment(){
        $data = array(
            'id_post' => $this->input->post('id_posting'),
            'id_user' => $this->input->post('id_user'),
            'comment' => $this->input->post('comment')
        );
        return $this->db->insert('tb_comment', $data);
    }
    
    function getComments($id_post) {
        $query = $this->db->query("SELECT c.id_comment, c.id_post, c.id_user, c.comment, u.profpic, u.nama
FROM tb_comment c, tb_user u
WHERE c.id_user = u.id_user AND id_post = '$id_post' ORDER BY id_comment ASC");

        if ($query->num_rows() != 0) {
            return $query->result();
        } else {
            return false;
        }
    }
}
?>
